package view;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

public class MainFrame extends JFrame {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 8456560429229699542L;
	private static final int WINDOW_WIDTH = 450;
	private static final int WINDOW_HEIGHT = 350;
	
	public MainFrame() {
		super();
		
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);	
		
		// add the menu bar
		createMenuBar();
		
		// add the game panel
		this.add(new GamePanel());
		
		// set the size of the window
		this.setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
	}
	
	private void createMenuBar() {
		JMenuBar menuBar = new JMenuBar();

		// add the file menu
		JMenu fileMenu = new JMenu("File");
		fileMenu.setMnemonic('f');
		menuBar.add(fileMenu);
		
		// add the name game menu item
		JMenuItem newGameItem = new JMenuItem("New Game");
		newGameItem.setMnemonic('n');
		newGameItem.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {
				// TODO Call the game controller
				
			}
			
		});
		fileMenu.add(newGameItem);
		
		// add an exit button to the file menu
		JMenuItem exitMenuItem = new JMenuItem("Exit");
		exitMenuItem.setMnemonic('e');
		exitMenuItem.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
			
		});
		fileMenu.add(exitMenuItem);
		
		setJMenuBar(menuBar);
	}

}
